package com.mywiki.controller;

import com.mywiki.domain.Test;
import com.mywiki.po.Ebook;
import com.mywiki.resp.CommonResp;
import com.mywiki.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.UUID;

/**
 * describe:
 *
 * @author: robin
 * @date 2024/1/18 23:19
 */
@RestController
public class TestController {

    @Autowired
    private TestService testService;

    @RequestMapping(value = "hello", method = RequestMethod.GET)
    public String hello(String name){
        return  "hello world halo," + name;
    }

    @RequestMapping(value = "hello", method = RequestMethod.POST)
    public String helloPost(String name){
        return  "hello world," + name;
    }

    @PostMapping("/hello/ebook")
    public CommonResp ebookReq(String name){
        Ebook ebook = new Ebook();
        ebook.setId(UUID.randomUUID().toString());
        ebook.setName(name);
        return new CommonResp(true, "响应正确", ebook);
    }

    @GetMapping("/test/list")
    public List<Test> list(){
        List<Test> list = testService.list();
        return list;
    }

}
